//
//  OneMultilinguaItem.m
//  lTTheOne
//
//  Created by sy on 2025/6/6.
//

#import "OneMultilinguaItem.h"
#import <Masonry/Masonry.h>
#import "HeaderConfig.h"

@implementation OneMultilinguaItem
- (instancetype)init
{
    self = [super init];
    if (self) {
        [self createSubViews];
    }
    return self;
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}
- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews{
    self.backgroundColor = HEXColor(@"#008000");
    KViewRadius(self, 5);
    
    self.itemStackView = [[UIStackView alloc]initWithFrame:CGRectZero];
    self.itemStackView.axis = UILayoutConstraintAxisVertical;
    self.itemStackView.distribution = UIStackViewDistributionEqualSpacing;
    self.itemStackView.alignment = UIStackViewAlignmentFill;
    self.itemStackView.spacing = 0;
    [self addSubview:self.itemStackView];
    
    self.chinaLB = [[UILabel alloc] initWithFrame:CGRectZero];
    self.chinaLB.font = PingFangMedium(11);
    self.chinaLB.textColor = HEXColor(@"#FFFFFF");
    self.chinaLB.textAlignment = NSTextAlignmentCenter;
    [self.itemStackView addArrangedSubview:self.chinaLB];
    
    self.englishLB = [[UILabel alloc] initWithFrame:CGRectZero];
    self.englishLB.font = PingFangMedium(11);
    self.englishLB.textColor = HEXColor(@"#FFFFFF");
    self.englishLB.textAlignment = NSTextAlignmentCenter;
    [self.itemStackView addArrangedSubview:self.englishLB];
    
    self.chinaLB.numberOfLines = 0;
    self.englishLB.numberOfLines = 0;
}
- (void)layoutSubviews{
    [self.itemStackView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.centerY.equalTo(self);
        make.top.equalTo(self).offset(4);
    }];
    [self.chinaLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(13);
    }];
    [self.englishLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(13);
    }];
}

- (void)showNomalStyle{
    self.backgroundColor = [UIColor clearColor];
    self.chinaLB.font = KFont_M(18);
    self.englishLB.font = KFont_M(10);
    
}
- (void)showOpenStyle:(BOOL)isSelected{
    self.backgroundColor = isSelected?HEXColor(@"#008000"):HEXColor(@"#FFC301");
    UIColor *textColor = isSelected?HEXColor(@"#FFFFFF"):HEXColor(@"#000000");
    
    self.chinaLB.textColor = textColor;
    self.englishLB.textColor = textColor;
    
    self.chinaLB.font = KFont_M(11);
    self.englishLB.font = KFont_M(11);
    
    self.chinaLB.text = isSelected?@"已开通":@"开通";
    self.englishLB.text = isSelected?@"Activated":@"Activate";
    
}
- (void)showBackGroundColor:(UIColor*)bgColor{
    self.backgroundColor = bgColor;
}
- (void)showTitleFont:(UIFont*)chFont withEnFont:(UIFont*)enFont{
    self.chinaLB.font = chFont;
    self.englishLB.font = enFont;
}
- (void)showTextAlignment:(NSTextAlignment)alignement{
    self.chinaLB.textAlignment = alignement;
    self.englishLB.textAlignment = alignement;
}
- (void)showTitleStr:(NSString*)ch_Str withEnStr:(NSString*)en_Str{
    self.chinaLB.text = ch_Str;
    self.englishLB.text = en_Str;
}
- (void)showTitleColor:(UIColor*)ch_color withEnStr:(UIColor*)en_color{
    self.chinaLB.textColor = ch_color;
    self.englishLB.textColor = en_color;
}

@end


@implementation OneSetMenuItem

- (void)createSubViews{
    [super createSubViews];

    self.itemStackView.alignment = UIStackViewAlignmentLeading;
    self.itemStackView.spacing = 0;
}
- (void)layoutSubviews{
    [self.itemStackView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    [self.chinaLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_greaterThanOrEqualTo(25);
    }];
    
    [self.englishLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_greaterThanOrEqualTo(14);
    }];
}

@end


@implementation OneCodeSetMenuItem
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        UITextField *textField = [[UITextField alloc] init];
        textField.placeholder = @"授权码为全数字组合不支持符号";
        textField.textColor = HEXColor(@"#D8D8D8");
        textField.textAlignment = NSTextAlignmentCenter;
        textField.borderStyle = UITextBorderStyleNone;
        textField.keyboardType = UIKeyboardTypeNumberPad;
        textField.font = KFont_M(13);
        [self addSubview:textField];
        self.codeTextField = textField;
        
        self.lineView = [UIView new];
        self.lineView.backgroundColor = HEXColor(@"#D8D8D8");
        [self addSubview:self.lineView];
        
    }
    return self;
}
- (void)layoutSubviews{
    [self.codeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.left.equalTo(self).offset(0);
        make.top.equalTo(self).offset(14);
        make.height.mas_equalTo(21);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.left.equalTo(self).offset(0);
        make.top.equalTo(self.codeTextField.mas_bottom).offset(4);
        make.bottom.equalTo(self);
        make.height.mas_equalTo(1);
    }];
}
@end
